﻿@model Finance.Web.Models.Deposit

<form class="form-horizontal" name="depositForm">
  <div class="form-group">
    <label for="name" class="col-sm-2 control-label">Наименование</label>
    <div class="col-sm-8">
      <input class="form-control" name="Name" data-ng-model="model.Name" type="text" id="name" required>
      <span data-ng-show="depositForm.Name.$error.server">{{depositForm.Name.textErrors.server}}</span>
    </div>
  </div>
  <div class="form-group">
    <label for="info" class="col-sm-2 control-label">Информация</label>
    <div class="col-sm-8">
      <textarea class="form-control" name="Info" data-ng-model="model.Info" id="info" required></textarea>
      <span data-ng-show="depositForm.Info.$error.server">{{depositForm.Info.textErrors.server}}</span>
    </div>
  </div>
   <div class="form-group">
    <label for="info" class="col-sm-2 control-label">Банк</label>
    <div class="col-sm-8" data-ng-switch="" data-on="!model.Code">
        <input data-ng-switch-when="true" type="text" data-ng-model="model.Bank" placeholder="Выберите банк" name="Bank"  data-typeahead="state as state.Name for state in getBanks($viewValue)" class="form-control" required>
        <p data-ng-switch-default="" class="form-control">{{model.BankName}}</p>
    </div>
  </div>
   <div class="form-group" data-ng-show="!model.PercentAmountDepend">
    <label for="percent" class="col-sm-2 control-label">Процент</label>
    <div class="col-sm-8">
      <input type="number"  class="form-control" name="Percent" data-ng-model="model.Percent" id="percent" min="0" max="99">
    </div>
  </div>
   <div class="form-group">
    <div class="col-sm-8 col-sm-offset-2">
        <div class="checkbox">
        <label>
          <input type="checkbox" name="Capitalization" data-ng-model="model.Capitalization"> Капитализация
        </label>
      </div>
    </div>
  </div>
  <div class="form-group">
    <label for="frequency" class="col-sm-2 control-label">Частота начисления</label>
    <div class="col-sm-8">
        <select data-ng-model="model.PaymentFrequesny" id="frequency" name="PaymentFrequesny" required class="form-control">
            <option value="360">Непрерывное начисление</option>
            <option value="1">Раз в год</option>
            <option value="4">Каждые 3 месяца</option>
            <option value="12">Каждый месяц</option>
            <option value="24">Два раза в месяц</option>
        </select>
    </div>
  </div>
  <div class="form-group">
    <label for="period" class="col-sm-2 control-label">Срок вклада (месяцев)</label>
    <div class="col-sm-8">
        <input type="number" data-ng-model="model.PeriodPayment"  min="0" max="100" name="PeriodPayment" id="period" required class="form-control"/>
    </div>
  </div>
  <div class="form-group">
    <div class="col-sm-8 col-sm-offset-2">
        <div class="checkbox">
        <label>
          <input type="checkbox" name="PercentAmountDepend" data-ng-model="model.PercentAmountDepend"> Ставка зависит от суммы вклада
        </label>
      </div>
    </div>
  </div>
    <div class="form-group" data-ng-show="model.PercentAmountDepend">
        <div class="col-sm-8 col-sm-offset-2">
            <table class="table table-hover table-bordered">
                <thead>
                    <tr>
                        <th>#</th>
                        <th>От</th>
                        <th>До</th>
                        <th>Процент</th>
                        <th><a data-ng-click="addDep(model)" class="glyphicon glyphicon-plus"></a></th>
                    </tr>
                </thead>
                <tbody>
                    <tr data-ng-repeat="dep in model.PercentAmountDepends">
                        <td>{{$index+1}}</td>
                        <td><input type="number" data-ng-model="dep.MinAmount"/></td>
                        <td><input type="number" data-ng-model="dep.MaxAmount"/></td>
                        <td><input type="number" data-ng-model="dep.Percent"/></td>
                        <td><a data-ng-click="removeDep(model, dep)" class="glyphicon glyphicon-remove"></a></td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-8 col-sm-offset-2">
            <div class="checkbox">
            <label>
              <input type="checkbox" name="HasPenalties" data-ng-model="model.HasPenalties"> Есть штрафы
            </label>
          </div>
        </div>
    </div>

    <div class="form-group" data-ng-show="model.HasPenalties">
        <div class="col-sm-8 col-sm-offset-2">
            <table class="table table-hover table-bordered">
                <thead>
                    <tr>
                        <th>#</th>
                        <th>От</th>
                        <th>До</th>
                        <th>Процент</th>
                        <th><a data-ng-click="addPen(model)" class="glyphicon glyphicon-plus"></a></th>
                    </tr>
                </thead>
                <tbody>
                    <tr data-ng-repeat="dep in model.PercentPenalties">
                        <td>{{$index+1}}</td>
                        <td><input type="number" data-ng-model="dep.From"/></td>
                        <td><input type="number" data-ng-model="dep.To"/></td>
                        <td><input type="number" data-ng-model="dep.Percent"/></td>
                        <td><a data-ng-click="removePen(model, dep)" class="glyphicon glyphicon-remove"></a></td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>

  <div class="form-group">
    <div class="col-sm-offset-2 col-sm-2">
      <button type="submit" data-ng-click="createModel()" class="btn">Сохранить</button>
    </div>
    <div class="col-sm-2">
      <button data-ng-click="cancel()" class="btn">Отмена</button>
    </div>
  </div>  
</form>